//
//  AuditScoreViewController.m
//  DigiOps
//
//  Created by app on 2018/7/24.
//  Copyright © 2018年 俞渊华. All rights reserved.
//

#import "AuditScoreViewController.h"
#import "PointValueModel.h"

@interface AuditScoreViewController ()
@property(nonatomic, strong)UITableView *tableView;
@property(nonatomic, strong)NSMutableArray *scoreArray;

@end

@implementation AuditScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    CGRect labelFrame = CGRectMake(0.0, 0.0, SCREEN_WIDTH, 36.0);
    UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
    label.font = [UIFont boldSystemFontOfSize:18];
    label.numberOfLines = 2;
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentLeft;
    label.textColor = [UIColor whiteColor];
    //    label.shadowColor = [UIColor blackColor];
    //    label.shadowOffset = CGSizeMake(0.0, -1.0);
    label.lineBreakMode = UILineBreakModeMiddleTruncation;
    label.text=@"审查";
    self.navigationItem.titleView = label;

    [self.view addSubview:self.tableView];
    
    //默认block方法：设置上拉加载更多
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    self.scoreArray=[NSMutableArray new];
//    self.scoreArray=@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
    
    for (PointValueModel* p in self.model.valueArr) {
        [self.scoreArray addObject:p.value];
    }
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
}


-(void)searchAticle{
    
}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        return self.scoreArray.count;
//    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //    RouteModel * model = self.routeArray[indexPath.row];
    //    if (model.ViewType == 1) {
    //        HomeBaseCell * cell = [HomeBaseCell cellWithTableView:tableView];
    //        //        cell.model = model;
    //        return cell;
    //    }else if (model.ViewType == 2) {
    //        HomeOneImageCell *cell = [HomeOneImageCell cellWithTableView:tableView];
    //        cell.model = model;
    //        return cell;
    //    }else if (model.ViewType == 3){
    //        NewsMoreImageCell * cell = [NewsMoreImageCell cellWithTableView:tableView];
    //        //        cell.model = model;
    //        return cell;
    //    }else if (model.ViewType == 4){
    //        HomeOneImageCell *cell = [HomeOneImageCell cellWithTableView:tableView];
    //        cell.model = model;
    //        return cell;
    //        //        NewsVideoCell * cell = [NewsVideoCell cellWithTableView:tableView];
    //        ////        cell.model = model;
    //        //        return cell;
    //    }
    UITableViewCell* cell=[[UITableViewCell alloc] init];
    cell.textLabel.text=[self.scoreArray objectAtIndex:indexPath.row];
    cell.textLabel.textAlignment = NSTextAlignmentCenter;//文字居中
    //    cell.model=[RouteModel new];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    //    AticleModel * model = self.aticleArray[indexPath.row];
    //    if (model.ViewType == 1) {
    //        return [HomeBaseCell heightWithModel:model];
    //
    //    }else if (model.ViewType == 2) {
    //        return [HomeOneImageCell heightWithModel:model];
    //
    //    }else if (model.ViewType == 3){
    //        return [NewsMoreImageCell heightWithModel:model];0
    //    }else if (model.ViewType == 4){
    //        return [HomeOneImageCell heightWithModel:model];
    //    }
    return 60;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.block) {
        self.block([self.scoreArray objectAtIndex:indexPath.row],self.model.seq);
    }
    [self.rt_navigationController popViewControllerAnimated:YES];

    /*
     NewsDetailViewController * detailVC = [[NewsDetailViewController alloc]init];
     detailVC.model = self.aticleArray[indexPath.row];
     [self.rt_navigationController pushViewController:detailVC animated:YES];
     */
//    DetailViewController * detailVC = [[DetailViewController alloc]init];
//    //    detailVC.model = self.aticleArray[indexPath.row];
//    [self.rt_navigationController pushViewController:detailVC animated:YES];
}


- (UITableView *)tableView{
    if (!_tableView) {
        UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.tableFooterView = [UIView new];
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
        view.backgroundColor = XMColor(241, 245, 247);
        UILabel* titleLabel = [[UILabel alloc]init];
        titleLabel.font = [UIFont xm_medium:17.0];
        titleLabel.numberOfLines = 1;
        titleLabel.textColor = [UIColor xm_jetblackColor];
        titleLabel.text=@"审查通用";
        
        [view addSubview:titleLabel];
//        tableView.tableHeaderView=view;
        
        UIView * viewFoot = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
        viewFoot.backgroundColor = [UIColor whiteColor];
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        //        button.frame = CGRectMake(40, 100, SCREEN_WIDTH- 80, 30);
        button.backgroundColor = [UIColor lightGrayColor];
        [button setTitle:@"提交" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(submitRoute) forControlEvents:UIControlEventTouchUpInside];
        [viewFoot addSubview:button];
//        tableView.tableFooterView=viewFoot;
        //        [button setImage:[UIImage imageNamed:@"image"] forState:UIControlStateNormal];
        //        [button setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
        //        [button setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(view).offset(18);
            make.left.equalTo(view.mas_left).offset(20);
        }];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(viewFoot).offset(0);
            //            make.top.equalTo(view).offset(5);
            make.width.mas_equalTo(SCREEN_WIDTH-80);
            make.height.mas_equalTo(30);
            //            make.left.equalTo(view.mas_left).offset(20);
        }];
        _tableView = tableView;
    }
    return _tableView;
}
-(void)submitRoute
{
    
}

@end
